package com.jxb.ractBase;

import java.time.Duration;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;

import reactor.core.publisher.Flux;

/**
 * 类注释
 *
 * @author jiaobo
 * @date Created in 2024/10/23 20:58
 **/
public class FluxGenerTest {

    public static void main(String[] args) throws InterruptedException {
        // AtomicLong atomicLong = new AtomicLong(1);
        // Flux<Object> objectFlux = Flux.generate(item -> {
        //     item.next(atomicLong.getAndIncrement());
        // }).delayElements(Duration.ofSeconds(1));
        //
        // objectFlux.subscribe(item->{
        //     System.out.println("first subscriber: "+item);
        // });
        //
        // objectFlux.subscribe( item->{
        //     System.out.println("second subscriber: "+item);
        // } );
        //
        // TimeUnit.SECONDS.sleep(Integer.MAX_VALUE );

        Flux.create(item -> {
            item.next(UUID.randomUUID().toString());
        }).subscribe(System.out::println);
        TimeUnit.SECONDS.sleep(Integer.MAX_VALUE );
    }

}
